package com.imooc.miaosha.redis.keys;

/**
 * 模块描述: <br>
 * (redis前缀抽象类)
 *
 * @Author: Mr. xyb
 * @Date: 2019/4/14 17:03
 * @since: 1.8.0
 * @version: 1.0.0
 */
public abstract class BasePrefix implements KeyPrefix {

    /**
     * 过期时间
     */
    private int expireSeconds;

    /**
     * 前缀
     */
    private String prefix;

    public BasePrefix(String prefix) {// 0为永不过期
        this(0, prefix);
    }


    public BasePrefix(int expireSeconds, String prefix) {
        this.expireSeconds = expireSeconds;
        this.prefix = prefix;
    }

    public void setExpireSeconds(int expireSeconds) {
        this.expireSeconds = expireSeconds;
    }

    @Override
    public int expireSeconds() {
        return expireSeconds;
    }


    @Override
    public String getPrefix() {
        String className = getClass().getSimpleName();
        return className + ":" + prefix;
    }
}
